import { SUPPLIER_TYPE_SELECT_LIST, SUPPLIER_NATURE_SELECT_LIST } from './common'
import { list2Obj } from './../utils';

const SUPPLIER_TYPE_MAP_OBJECT = list2Obj(SUPPLIER_TYPE_SELECT_LIST)

// 供应商管理 - 线索供应商
const INITIAL_FIELDS_VALUE = {
  supplierCode: '',
  supplierName: '',
  mainCategoryCode: '',
  mainCategoryName: '',
  businessCategoryCode: '',
  businessCategory: '',
  mainGoods: '',
  supplierNature: '',
  supplierType: '',
}
const FORM_ITEM_LIST = [
  {
    prop: 'supplierCode',
    label: '供应商代码',
    type: 'input',
  },
  {
    prop: 'supplierName',
    label: '供应商名称',
    type: 'input',
  },
  {
    prop: 'mainCategoryCode',
    label: '主营品类代码',
    type: 'input',
  },
  {
    prop: 'mainCategoryName',
    label: '主营品类',
    type: 'input',
  },
  {
    prop: 'businessCategoryCode',
    label: '经营品类代码',
    type: 'input',
  },
  {
    prop: 'businessCategory',
    label: '经营品类',
    type: 'input',
  },
  {
    prop: 'mainGoods',
    label: '主营商品',
    type: 'input',
  },
  {
    prop: 'supplierNature',
    label: '供应商性质',
    type: 'select',
    clearable: true,
    options: SUPPLIER_NATURE_SELECT_LIST
  },
  {
    prop: 'supplierType',
    label: '供应商类型',
    type: 'select',
    clearable: true,
    options: SUPPLIER_TYPE_SELECT_LIST
  },
]
const TABLE_COLUMNS = [
  {
    title: '序号',
    type: 'seq',
    width: 50
  },
  {
    title: '供应商代码',
    field: 'supplierCode',
  },
  {
    title: '供应商名称',
    field: 'supplierName',
  },
  {
    title: '供应商来源',
    field: 'supplierSource',
  },
  {
    title: '主营品类代码',
    field: 'mainCategoryCode',
  },
  {
    title: '主营品类',
    field: 'mainCategoryName',
  },
  {
    title: '经营品类代码',
    field: 'businessCategoryCode',
  },
  {
    title: '经营品类',
    field: 'businessCategory',
  },
  {
    title: '主营商品',
    field: 'mainGoods',
  },
  {
    title: '供应商类型',
    field: 'supplierType',
    formatter: ({ cellValue, row, column }) => {
      return SUPPLIER_TYPE_MAP_OBJECT[cellValue]
    }
  },
  {
    title: '管理区域',
    field: 'managementArea',
  },
  {
    title: '供应商归属中心',
    field: 'attributionCenter',
  },
  {
    title: '是否走手续',
    field: 'goThroughFormalities',
  },
  {
    title: '创建人',
    field: 'createBy',
  },
  {
    title: '创建日期',
    field: 'createDate',
  },
  {
    title: '发票类型',
    field: 'invoiceType',
  },
  {
    title: '税票率1',
    field: 'taxTicketRate1',
  },
  {
    title: '税票率2',
    field: 'taxTicketRate2',
  },
  {
    title: '操作',
    showOverflow: false,
    minWidth: 200,
    slots: { default: 'operate' }
  }
]
export default {
  INITIAL_FIELDS_VALUE,
  FORM_ITEM_LIST,
  TABLE_COLUMNS
}
